package com.yihong.portalserver.controller;

import com.yihong.common.entity.User;
import com.yihong.common.util.AjaxJson;
import com.yihong.common.util.JwtUtil;
import com.yihong.portalserver.feign.UserFeign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @ClassName UserController
 * @Description
 * @Author 孟志浩
 * @Date 2019/3/18 11:35
 **/
@RestController
@RequestMapping("/user")
public class UserController {

    private static  final Logger LOG = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserFeign userFeign;

    @GetMapping("/list")
    public List<User> listUser(HttpServletRequest request){
        String authorization = request.getHeader("Authorization");
        LOG.info("Portal微服务 获取到token：{}", authorization);
        return userFeign.listUsers();
    }

    @PostMapping("/login")
    public AjaxJson login(User user) {
        return userFeign.login(user);
    }

}
